package com.ib.review.base.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.ib.review.base.utils.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UtilsConfig {
    @Bean
    public UploadFiles uploadFiles() {
        return new UploadFiles();
    }
    @Bean
    public MinioService minioService(@Value("${minio.endpoint}") String endpoint,
                                     @Value("${minio.access-key}") String accessKey,
                                     @Value("${minio.secret-key}") String secretKey) {
        return new MinioService(endpoint,accessKey,secretKey);
    }
    @Bean
    public ExcelHeaderParser excelHeaderParser(){
        return new ExcelHeaderParser();
    }
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 添加分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL)); // 指定数据库类型
        return interceptor;
    }
}
